package com.zprmb.udzt;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
 * 绑卡成功界面
 * @author shenshao
 *
 */
public class BindCard_Success extends BaseActivity implements OnClickListener{
	private String tiyan="",auth;
	private TextView tv_tiyan,img_tiyan,tv_title,tv_status;
	private int who=0;
	private Button in_exe,inadd;
	private ImageView img_back;
	private int isbank,isexe;
	private RelativeLayout rl_back;
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bind_success);
		 BbtApplication.getInstance().addActvity(this);
		tv_tiyan=(TextView)findViewById(R.id.tiyan_money);
		img_tiyan=(TextView)findViewById(R.id.img_tiyan_money);
		in_exe=(Button)findViewById(R.id.in_exegold);
		inadd=(Button)findViewById(R.id.in_addmoney);
		img_back=(ImageView)findViewById(R.id.img_back);
		tv_status=(TextView)findViewById(R.id.tv_status);
		tv_title=(TextView)findViewById(R.id.tv_title);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		rl_back.setOnClickListener(this);
		img_back.setOnClickListener(this);
		in_exe.setOnClickListener(this);
		inadd.setOnClickListener(this);
		isexe=getIntent().getIntExtra("isexe", 0);
		isbank=getIntent().getIntExtra("isbank", 0);
		
		if(isbank==1){
			tv_status.setText("信息已完善");
			tv_title.setText("完善成功");
		}
		who=getIntent().getIntExtra("who", 0);
//		if(getIntent().getBooleanExtra("flag", true)){
//		
//				
//				tiyan=getIntent().getStringExtra("tiyan");	
//			
//			tv_tiyan.setText(tiyan+"元体验金");
//			img_tiyan.setText(tiyan);
//		}else{
//			tiyan=getIntent().getStringExtra("tiyan");
//			auth=getIntent().getStringExtra("auth");
//			double money=Double.parseDouble(tiyan)+Double.parseDouble(auth);
//			tv_tiyan.setText(String.valueOf(money)+"元体验金");
//			img_tiyan.setText(String.valueOf(money));
//		}
//		Log.e("success1", getIntent().getStringExtra("rate1")+"天");
//		Log.e("success2", getIntent().getStringExtra("rate2")+"天");
//		Log.e("success3", getIntent().getStringExtra("rate3")+"天");
		Intent intent=new Intent(BindCard_Success.this,Bind_Bank_Gift.class);
		intent.putExtra("coupon1", getIntent().getStringExtra("coupon1"));
		intent.putExtra("coupon2", getIntent().getStringExtra("coupon2"));
		intent.putExtra("coupon3", getIntent().getStringExtra("coupon3"));
		intent.putExtra("rate1", getIntent().getStringExtra("rate1"));
		intent.putExtra("rate2", getIntent().getStringExtra("rate2"));
		intent.putExtra("rate3", getIntent().getStringExtra("rate3"));
		startActivity(intent);
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (who==3) {
				//return false;
				Intent intent = new Intent(this,MyBankCard.class);
				startActivity(intent);
				finish();
			}else {
				 Intent mIntent = new Intent();
	                mIntent.setAction("exit");
	                sendBroadcast(mIntent);
				finish();
				return super.onKeyDown(keyCode, event);
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.in_exegold:
			Intent intent=new Intent(BindCard_Success.this,MainActivity.class);
			startActivity(intent);
			break;
		case R.id.in_addmoney:
			Intent intent2=new Intent(BindCard_Success.this,V4AddMoneySActiviy.class);
			startActivity(intent2);
			break;
		case R.id.img_back:
			if (who==3) {
				//return false;
				Intent intent3 = new Intent(BindCard_Success.this,MyBankCard.class);
				startActivity(intent3);
				finish();
			}else {
				Intent mIntent = new Intent();
                mIntent.setAction("exit");
                sendBroadcast(mIntent);
				finish();
			}
			break;
		case R.id.rl_back:
			if (who==3) {
				//return false;
				Intent intent3 = new Intent(BindCard_Success.this,MyBankCard.class);
				startActivity(intent3);
				finish();
			}else {
				Intent mIntent = new Intent();
                mIntent.setAction("exit");
                sendBroadcast(mIntent);
				finish();
			}
			break;
		}
		
	}

}
